<template>
	<view>
		<view class="cu-bar search bg-white searchs">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input v-model="phone" type="number" placeholder="请输入手机号" confirm-type="search"></input>
			</view>
		</view>
		<view class="xianshi" v-if="phone" @click="applyAdd">找人 : {{phone}}</view>
		<view class="xianshi" v-if="phone" @click="applyAddGroup">找群 : {{phone}}</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				phone: ''
			};
		},
		onShow() {
			this.$msgchat.initwork();
		},
		methods: {
			//加好友
			applyAdd() {
				this.$common.requests('/api/friend_add/search', {phone: this.phone}).then(res => {
					if (res.data.code == 1) {
						if(res.data.data == 0){
							this.$api.msg("没有此人");
						}else{
							uni.navigateTo({
								url: '../applyAdd/applyAdd?phone=' + this.phone
							});
						}
					} else {
						this.$api.msg(res.data.msg);
					}
				})
			},
			applyAddGroup(){
				this.$common.requests('/api/group/findqun', {search: this.phone}).then(res => {
					console.log(res.data)
					if(res.data.data == 0){
						this.$api.msg("没有此群");
						console.log(res.data.data)
					}else{
						uni.navigateTo({
							url: '../applyAddGroup/applyAddGroup?search=' + this.phone
						});
					}
				})
			}
		}
	}
</script>

<style>
	page {
		width: 100vw;
		background: #F5F4F9;
	}

	.text-blue,
	.line-blue,
	.lines-blue {
		color: #09BB07;
	}
	.searchs{
		background: #F5F4F9;
	}
	.round{
		background: #FFFFFF;
		border-radius: 15upx;
	}
	.xianshi {
		margin: 0 35upx;
		padding: 25upx 0;
	}
</style>
